package com.itserver.controller.sysController;


import com.itserver.pojo.PageResult;
import com.itserver.pojo.Result;
import com.itserver.pojo.sys.Post;
import com.itserver.service.sys.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sys/post")
public class PostController {
    @Autowired
    private PostService postService;
    //部门列表
    @GetMapping
    public Result list(){
        PageResult<Post> pageResult = postService.list();
        return Result.success(pageResult);
    }
    //新增部门
    @PostMapping
    public Result add(@RequestBody Post post){
        postService.add(post);
        return Result.success();
    }

    @PutMapping
    //修改部门
    public Result update(@RequestBody Post post){
        postService.update(post);
        return Result.success();
    }

    @DeleteMapping
    public Result delete(@RequestParam List<Integer> ids){
        postService.delete(ids);
        return Result.success();
    }

    @GetMapping("/{id}")
    public Result getById(@PathVariable Integer id){
        Post post = postService.getById(id);
        return  Result.success(post);
    }

}
